home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "VB to Excel"
- ClientHeight = 3585
- ClientLeft = 1635
- ClientTop = 1485
- ClientWidth = 6675
- Height = 3990
- Left = 1575
- LinkTopic = "Form1"
- ScaleHeight = 3585
- ScaleWidth = 6675
- Top = 1140
- Width = 6795
- Begin CommandButton Command1
- Caption = "OLE Automation to Excel"
- Height = 855
- Left = 1680
- TabIndex = 0
- Top = 1200
- Width = 2535
- End
- Option Explicit
- Sub Command1_Click ()
- On Error GoTo errole
- Dim xl As object
- Set xl = GetObject(, "excel.application")
- xl.workbooks.Add
- xl.visible = True
- xl.Range("A1").Select
- xl.ActiveCell.FormulaR1C1 = "4"
- xl.Range("A2").Select
- xl.ActiveCell.FormulaR1C1 = "5"
- xl.Range("A3").Select
- xl.ActiveCell.FormulaR1C1 = "6"
- xl.Range("A4").Select
- xl.ActiveCell.FormulaR1C1 = "3"
- xl.Range("A1:A4").Select
- xl.ActiveSheet.ChartObjects.Add(81, 41.25, 267, 124.5).Select
- xl.Application.CutCopyMode = False
- xl.ActiveChart.ChartWizard xl.Range("A1:A4"), 3, 6, 2, 0, 0, 1
- Exit Sub
- errole:
- If Err = 429 Then
- Set xl = CreateObject("Excel.application.5")
- Resume Next
- End If
- End Sub
-